<?php

use Illuminate\Support\Facades\Route;

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/

Route::namespace('Api')->group(function (){

    Route::any('upload', 'BannerController@upload');//上传

    Route::post('wechat/code-login', 'WechatController@codeLogin');//静默登录

    //需要登录的请求
    Route::middleware(['api.auth'])->group(function (){

        Route::get('user', 'UserController@index');//用户信息
        Route::post('user/mobile', 'UserController@mobile');//授权手机

        Route::post('classify/selected', 'ClassifyController@selected');//启动页选择分类
        Route::post('classify/index', 'ClassifyController@index');//分类

        Route::post('book/detail', 'BookController@detail');//书本详情
        Route::post('book/chapter', 'BookController@chapter');//章节详情
        Route::post('book/start-chapter', 'BookController@startChapter');//开始阅读章节
        Route::post('book/word', 'BookController@word');//提交单词选项
        Route::post('book/turn', 'BookController@turn');//章节关卡复习进度提交
        Route::post('book/progress', 'BookController@progress');//章节关卡复习进度提交

        Route::post('report/create', 'ReportController@create');//报错提交
        Route::post('roast/upload-img', 'RoastController@uploadImg');//吐槽图片
        Route::post('roast/create', 'RoastController@create');//吐槽提交


        Route::post('sign/create', 'SignController@create');//打卡
        Route::post('sign/list', 'SignController@list');//打卡日历

        Route::post('subscribe/create', 'SubscribeController@create');//模板事件上报
        Route::post('subscribe/change', 'SubscribeController@change');//模板状态变更


        Route::post('user/wx-profile', 'UserController@wxProfile');//更新微信用户信息
        Route::post('user/profile', 'UserController@profile');//修改信息
        Route::post('user/wx-auth', 'UserController@wxAuth');//授权用户头像信息


        Route::post('order/price', 'OrderController@price');//会员价格
        Route::post('order/create', 'OrderController@create');//创建订单
        Route::post('order/result', 'OrderController@result');//支付结果
    });


    Route::post('order/notify', 'OrderController@notify');//


    #H5网页
    Route::post("wx-share", "WechatController@wxShare");//获取分享接口
    Route::post("get-auth-by-code", "WechatController@getAuthByCode");//获取微信信息


    //小程序登录,两个登录不要短时间一起用

    Route::post('wechat/wx-login', 'WechatController@wxLogin');//授权登录

    Route::any('wechat/message', 'WechatController@message');//小程序客服消息回调

    Route::get('un-auth', 'UserController@unAuth');//未授权地址

    Route::get('index', 'BannerController@index');//广告位
    Route::get('banner', 'BannerController@banner');//广告位

    Route::any('official/message', 'OfficialController@message');//公众号消息回调
});

//  ===============七牛===============
Route::prefix('qiniu')->namespace('Qiniu')->group(function (){
    Route::get('token/url', 'TokenController@url');//获取上传key
    Route::post('upload-file', 'TokenController@uploadFile');//上传图片
});
